﻿//Include("Mz");

/**
 * @fileoverview 将后一个JSON对象合并到前一个JSON对象中
 * @author meizz
 * @version 20090425
 *
 * @name Mz.extend
 * @namespace Mz.extend
 * @param {Object} target JS对象
 * @param {JSON} source 被合并的JSON对象
 * @param {JSON} defaults [可选]合并操作前JS对象的初始值
 * @return {Object} 合并后的JSON对象
 */
Mz.extend = function(target, source, defaults) {
    if (typeof target != "object" || !target) {
        return target;
    }

    if (typeof defaults == "object" && defaults != null ) {
        Mz.extend(target, defaults);
    }

    if (target && source && typeof source == "object") {
        for (var p in source) {
            target[p] = source[p];
        }
    }
    return target;
};